package com.cntaiping.workutil.ocr;

import com.tencentcloudapi.common.Credential;
import com.tencentcloudapi.common.profile.ClientProfile;
import com.tencentcloudapi.common.profile.HttpProfile;
import com.tencentcloudapi.ocr.v20181119.OcrClient;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class TencentOcrConfigure {

    @Value("${tencent.secret-id}")
    private String secretId;

    @Value("${tencent.secret-key}")
    private String secretKey;

    @Value("${tencent.ocr-url}")
    private String ocrUrl;

    @Value("${taiping.proxy.url}")
    private String proxyUrl;

    @Value("${taiping.proxy.port}")
    private String proxyPort;

    @Bean
    public OcrClient ocrClient() {
        Credential cred = new Credential(secretId, secretKey);

        HttpProfile httpProfile = new HttpProfile();
        httpProfile.setProxyHost(proxyUrl);
        httpProfile.setProxyPort(Integer.parseInt(proxyPort));
        httpProfile.setEndpoint(ocrUrl);

        ClientProfile clientProfile = new ClientProfile();
        clientProfile.setHttpProfile(httpProfile);

        return new OcrClient(cred, "ap-shanghai", clientProfile);
    }
    /*
tencent:
  secret-id: AKIDRdzd3BePUIrBI8o3CAw2sWu04qZ2lgsn
  secret-key: mHuIWUSB58x61e17zoOi03qnji140hyz
  ocr-url: ocr.tencentcloudapi.com

#代理-腾讯云访问
taiping:
  proxy:
    url: 10.28.178.1
    port: 31151
    */
}